<?php
header("Content-type:application/json;charset=utf-8");

//查询前5条数据
$mysqli = new mysqli("vyuyzmoglbsq.rds.sae.sina.com.cn", "fuxiaohui", "123456", "h7", 10346);

if ($mysqli->connect_errno) {
  exit("数据库连接失败:".$mysqli->connect_error);
}

//设置结果的编码格式, 当有中文出现时使用
$mysqli->set_charset("utf8");

$sql = "select * from money order by score desc limit 5";

$result = $mysqli->query($sql); 

//记录查询结果对象
$arr = array();
while ($row = $result->fetch_object()) {
	//把对象放入数组中
	array_push($arr, $row);
}

echo json_encode($arr);

$mysqli->close();

?>